#include "sl_list.h"

void test_s_list_one()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	s_list_push_front(&plist, 1);
	s_list_print(plist);

	s_list_push_front(&plist, 2);
	s_list_print(plist);

	s_list_push_front(&plist, 3);
	s_list_print(plist);

	s_list_push_front(&plist, 4);
	s_list_print(plist);

}

void test_s_list_two()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	s_list_pop_back(&plist);
	s_list_print(plist);

	s_list_pop_back(&plist);
	s_list_print(plist);

	s_list_pop_back(&plist);
	s_list_print(plist);

	s_list_pop_back(&plist);
	s_list_print(plist);
}

void test_s_list_three()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	s_list_pop_front(&plist);
	s_list_print(plist);

	s_list_pop_front(&plist);
	s_list_print(plist);

	s_list_pop_front(&plist);
	s_list_print(plist);

	s_list_pop_front(&plist);
	s_list_print(plist);

}

void test_s_list_four()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);

	slt_node* pos = s_list_find(plist, 1);
	printf("%p\n", pos);

	pos = s_list_find(plist, 2);
	printf("%p\n", pos);

	pos = s_list_find(plist, 3);
	printf("%p\n", pos);

	pos = s_list_find(plist, 4);
	printf("%p\n", pos);

	pos = s_list_find(plist, 5);
	printf("%p\n", pos);
}

void test_s_list_five()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);


	slt_node* pos = s_list_find(plist, 1);
	s_list_insert(&plist, pos, 1);
	s_list_print(plist);

	pos = s_list_find(plist, 2);
	s_list_insert(&plist, pos, 2);
	s_list_print(plist);

	pos = s_list_find(plist, 2);
	s_list_insert(&plist, pos, 3);
	s_list_print(plist);

}

void test_s_list_seven()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	slt_node* pos = s_list_find(plist, 2);
	s_list_erase(&plist, pos);
	s_list_print(plist);
}
 
void test_s_list_eight()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	slt_node* pos = s_list_find(plist, 1);
	s_list_erase_after(pos);
	s_list_print(plist);
	s_list_destroy(&plist);
	s_list_print(plist);
}

void test_s_list_nine()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	slt_node* pos = s_list_find(plist, 1);
	s_list_erase_after(pos);
	s_list_print(plist);
	s_list_destroy(&plist);
	s_list_print(plist);
}

void test_s_list_ten()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	int pos = s_list_find_two(plist, 1);
	printf("%d\n", pos);
}

void test_s_list_eleven()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	int pos = s_list_find_two(plist, 1);
	s_list_insert_two(&plist, pos, 1);
	s_list_print(plist);

}

void test_s_list_twelve()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	int pos = s_list_find_two(plist, 1);
	s_list_insert_two_after(&plist, pos, 1);
	s_list_print(plist);
}

void test_s_list_thirteen()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	int pos = s_list_find_two(plist, 2);
	s_list_erase_two(&plist, pos);

	s_list_print(plist);
}

void test_s_list_fourteen()
{
	slt_node* plist = NULL;
	s_list_push_back(&plist, 1);
	s_list_push_back(&plist, 2);
	s_list_push_back(&plist, 3);
	s_list_push_back(&plist, 4);
	s_list_print(plist);

	int pos = s_list_find_two(plist, 4);
	s_list_erase_two_after(&plist, pos);
	s_list_print(plist);
}

int main()
{
	//test_s_list_one();
	//test_s_list_two();
	//test_s_list_three();
	//test_s_list_four();
	//test_s_list_five();
	//test_s_list_six();
	//test_s_list_seven();
	//test_s_list_eight();
	//test_s_list_nine();
	//test_s_list_ten();
	//test_s_list_eleven();
	//test_s_list_twelve();
	//test_s_list_thirteen();
	test_s_list_fourteen();

	return 0;
}